import React, { useEffect } from "react";
import { useNavigate } from "react-router-dom";
import sendFetch from "@/fetch";

export default function Logout() {
  const navigator = useNavigate();

  useEffect(() => {
    sendFetch(`/user/logout`, null, "POST").then(() => {
      localStorage.removeItem("login_token");
      localStorage.removeItem("refresh_token");
      navigator("/login");
      window.location.reload();
    });
  });

  return <div>Logout</div>;
}
